import request from '@/utils/request'


// 根据token获取用户信息
export function getUserInfo(token) {
  return request({
    url: '/user/getInfo',
    method: 'GET',
    params: { token }
  })
}


//分页查询用户所有信息
export function selectAllUserByPage(data) {
  return request({
    url: '/user/selectPage',
    method: 'GET',
    params:data
  })
}


//根据用户id删除用户，只删除一个
export function delUserById(id) {
  return request({
    url: '/user/deleteById',
    method: 'DELETE',
    params:{id}
  })
}


//批量删除用户
export function batchDelByIds(ids) {
  // 对ids列表进行转换
  ids = ids.join(',')
  return request({
    url: '/user/batchDelUserByIds',
    method: 'DELETE',
    params: {ids:ids}
  })
}


// 添加用户
export function addUser(data) {

  return request({
    url: '/user/add',
    method: 'POST',
    data
  })
}
// 修改用户信息
export function updateUser(data) {

  return request({
    url: '/user/put',
    method: 'PUT',
    data
  })
}


// 导入用户信息
export function uploadExcel(data) {

  return request({
    url: '/user/upload/excel',
    method: 'POST',
    data
  })
}

// 上传图片
export function uploadImage(formData) {
  return request({
    url: '/user/upload',
    method: 'POST',
    data: formData
  })
}

